import request from '@/utils/request';

/**
 * 分页查询用户
 */
export async function get_list(params) {
  const res = await request.post('/warehouse/receipts_store_check/get_list ', {
    ...params
  });
  if (res.data.code === 1) {
    return {
      list: res.data.data.row_list,
      columns: res.data.data.columns,
      searchData: res.data.data.search_area,
      count: res.data.data.page_info?.total,
      top_button: res.data.data.top_button
    };
  }
  return Promise.reject(new Error(res.data.msg));
}

/* 新建盘点单据 */
export async function check_add(params) {
  const res = await request.post('/warehouse/receipts_store_check/add', params);
  if (res.data.code === 1) {
    return res.data;
  }
  return Promise.reject(res.data.msg);
}
/* 盘点货品 */
export async function check_detail(params) {
  const res = await request.post(
    '/warehouse/receipts_store_check/detail',
    params
  );
  if (res.data.code === 1) {
    return res.data;
  }
  return Promise.reject(res.data.msg);
}
/* 继续盘点 */
export async function continue_check(params) {
  const res = await request.post(
    '/warehouse/receipts_store_check/continue_check',
    params
  );
  if (res.data.code === 1) {
    return res.data;
  }
  return Promise.reject(res.data.msg);
}
/* 编辑实盘数量 */
export async function check_edit_num(params) {
  const res = await request.post(
    '/warehouse/receipts_store_check/edit_num',
    params
  );
  if (res.data.code === 1) {
    return res.data;
  }
  return Promise.reject(res.data.msg);
}
/* 批量录入 */
export async function batch_enter(params) {
  const res = await request.post(
    '/warehouse/receipts_store_check/batch_enter',
    params
  );
  if (res.data.code === 1) {
    return res.data;
  }
  return Promise.reject(res.data.msg);
}
/* 重新盘点 */
export async function check_reset(params) {
  const res = await request.post(
    '/warehouse/receipts_store_check/reset',
    params
  );
  if (res.data.code === 1) {
    return res.data;
  }
  return Promise.reject(res.data.msg);
}
/* 取消盘点 */
export async function check_cancel(params) {
  const res = await request.post(
    '/warehouse/receipts_store_check/cancel',
    params
  );
  if (res.data.code === 1) {
    return res.data;
  }
  return Promise.reject(res.data.msg);
}
/* 结束盘点 */
export async function check_finish(params) {
  const res = await request.post(
    '/warehouse/receipts_store_check/finish_check',
    params
  );
  if (res.data.code === 1) {
    return res.data;
  }
  return Promise.reject(res.data.msg);
}
/* 盘点报告-盘点概况 */
export async function report_base(params) {
  const res = await request.post(
    '/warehouse/receipts_store_check/report_base',
    params
  );
  if (res.data.code === 1) {
    return res.data;
  }
  return Promise.reject(res.data.msg);
}
/* 盘点报告-盘亏货品 */
export async function report_loss(params) {
  const res = await request.post(
    '/warehouse/receipts_store_check/report_loss',
    params
  );
  if (res.data.code === 1) {
    return res.data;
  }
  return Promise.reject(res.data.msg);
}
/* 盘点报告-盘盈货品 */
export async function report_profit(params) {
  const res = await request.post(
    '/warehouse/receipts_store_check/report_profit',
    params
  );
  if (res.data.code === 1) {
    return res.data;
  }
  return Promise.reject(res.data.msg);
}
/* 生成报损单 */
export async function loss_receipts(params) {
  const res = await request.post(
    '/warehouse/receipts_store_check/loss_receipts',
    params
  );
  if (res.data.code === 1) {
    return res.data;
  }
  return Promise.reject(res.data.msg);
}
/* 生成报溢单 */
export async function profit_receipts(params) {
  const res = await request.post(
    '/warehouse/receipts_store_check/profit_receipts',
    params
  );
  if (res.data.code === 1) {
    return res.data;
  }
  return Promise.reject(res.data.msg);
}
/* 导出盘亏货品 */
export async function loss_export(params) {
  const res = await request.post(
    '/warehouse/receipts_store_check/loss_export',
    params
  );
  if (res.data.code === 1) {
    return res.data;
  }
  return Promise.reject(res.data.msg);
}
/* 导出盘亏货品 */
export async function profit_export(params) {
  const res = await request.post(
    '/warehouse/receipts_store_check/profit_export',
    params
  );
  if (res.data.code === 1) {
    return res.data;
  }
  return Promise.reject(res.data.msg);
}
